package app.texas.com.devilfishhouse.View.Fragment.home;

import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.universal_library.adapter.BaseAdapter;

import app.texas.com.devilfishhouse.Beans.HotShopBean;
import app.texas.com.devilfishhouse.R;

/**
 * Created by solin on 2018/5/29.
 */

public class HotShopRecycleViewAdapter extends BaseAdapter<HotShopBean, HotShopRecycleViewAdapter.HotShopHolderView> {
    private HotShopBean hotShopBean;
    private OnMyRecycleViewItemClickListener itemClickListener;

    public HotShopRecycleViewAdapter(Context mContext) {
        super(mContext);
    }

    @Override
    public HotShopHolderView onCreateViewHolder(ViewGroup parent, int viewType) {
        return new HotShopHolderView(mInflater.inflate(R.layout.item_hot_shop, parent, false));
    }

    @Override
    public void onBindViewHolder(HotShopHolderView holder, final int position) {

        if (!mItems.isEmpty() && mItems.size() > 0) {
            holder.ll_parent.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    if (itemClickListener != null)
                        itemClickListener.onItemClickListener(position);
                }
            });
//            hotShopBean = mItems.get(position);
//            holder.tv_item_content.setText(hotShopBean.getTitle());
//            setImageFromNet(holder.iv_hotshopIcon, hotShopBean.getLogo());
        }
    }

    class HotShopHolderView extends RecyclerView.ViewHolder {
        private ImageView iv_hotshopIcon;
        private RelativeLayout ll_parent;
        private TextView tv_item_content;

        public HotShopHolderView(View itemView) {
            super(itemView);
            iv_hotshopIcon = itemView.findViewById(R.id.iv_hotshopIcon);
            ll_parent = itemView.findViewById(R.id.ll_product_item);
            tv_item_content = itemView.findViewById(R.id.tv_item_content);
        }
    }

    public void setItemClickListener(OnMyRecycleViewItemClickListener itemClickListener) {
        this.itemClickListener = itemClickListener;
    }
}
